2 Copyright (C) 2024 Rubén Beltrán del Río
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see https://map.tranquil.systems.
19 struct MapNotes: View {
22 let lineWidth: CGFloat
28 ForEach(notes, id: \.id) { note in
29 Text(note.text.replacingOccurrences(of: "\\n", with: "\n")).font(.theme.note)
32 .foregroundColor(.map.labelColor)
33 .border(Color.map.vertexColor, width: lineWidth)
34 .frame(minWidth: 16.0, maxWidth: maxWidth, alignment: .topLeading)
37 width: w(note.position.x),
38 height: h(note.position.y)
44 func h(_ dimension: CGFloat) -> CGFloat {
45 max(0.0, min(mapSize.height, dimension * mapSize.height / 100.0))
48 func w(_ dimension: CGFloat) -> CGFloat {
49 max(0.0, min(mapSize.width, dimension * mapSize.width / 100.0))
55 mapSize: CGSize(width: 400.0, height: 400.0), lineWidth: 1.0,
58 id: 0, position: CGPoint(x: 50.0, y: 50.0),
60 "Notes can have a lot more text, so we need to make sure that they're resized correctly")